package com.youmu.shop.review.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.result.ResultUtils;
import com.youmu.shop.context.utils.UserContext;
import com.youmu.shop.order.service.OrderService;
import com.youmu.shop.review.service.ReviewService;
import com.youmu.shop.system.bean.PosterReview;

/**
 * 评价控制层
 * @author Administrator
 *
 */
@RestController
@RequestMapping(value = "review")
public class ReviewController {

	@Autowired
	private ReviewService reviewService;
	
	@Autowired
	private OrderService orderService;
	
	/**
	 *	用户评价提交
	 * @return
	 */
	@RequestMapping(value = "insertReviewByMember", method = RequestMethod.POST)
	public Object insertReviewByMember(PosterReview posterReview, 
			HttpServletRequest request){
		posterReview.setMember(UserContext.getUserInfo().getId());
		posterReview.setIp(request.getRemoteAddr());
		reviewService.insertReview(posterReview);
		return ResultUtils.createDefResult(null);
	}
	
	/**
	 *	查询配送人信息
	 * @return
	 */
	@RequestMapping(value = "selectPosterInfo", method = RequestMethod.GET)
	public Object selectPosterInfo(Long orderId){
		return ResultUtils.createDefResult(reviewService.selectPosterInfo(orderId));
	}
	
}
